#include <etcd/Client.hpp>
#include <etcd/KeepAlive.hpp>
#include <iostream>

int main() {
    std::string addr = "http://127.0.0.1:2379";
    etcd::Client client(addr);
    etcd::KeepAlive keepalive(client, 3);
    auto lease_id = keepalive.Lease();
    auto resp = client.put("/server/friend", "127.0.0.1:8080", lease_id).get();
    if(!resp.is_ok()) {
        std::cerr << "Failed to put key: " << resp.error_message() << std::endl;
        return 1;
    }
    resp = client.put("/server/user", "127.0.0.1:8088", lease_id).get();
    if(!resp.is_ok())  {
        std::cerr << "Failed to put key: " << resp.error_message() << std::endl;
        return 1;
    }
    // client.rm("/server/user").get();
    std::this_thread::sleep_for(std::chrono::seconds(5));
    return 0;
}